﻿#include "setup4wind.h"
#include "ui_setup4wind.h"
#include <mainwindow.h>
extern intListener doorStatus;
setup4wind::setup4wind(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::setup4wind)
{
    ui->setupUi(this);
    connect(&doorStatus, &intListener::valueChanged,this,&setup4wind::doorStatusChanged,Qt::QueuedConnection);
}
void setup4wind::doorStatusChanged(){
    if(doorStatus.get()==0)
    {
        ui->pushButton_10->setText("        打开仓门");
    }
    else
    {
        ui->pushButton_10->setText("        关闭仓门");
    }
}

setup4wind::~setup4wind()
{
    delete ui;
}

void setup4wind::showEvent(QShowEvent *event)
{
    tcpClient = TcpClient::getInstance();
    if(doorStatus.get()==0)
    {
        ui->pushButton_10->setText("        打开仓门");
    }
    else
    {
        ui->pushButton_10->setText("        关闭仓门");
    }
    event->accept();
}

void setup4wind::on_returnBtn_2_clicked()
{
    this->close();
    emit changeTotalWindow();
}


void setup4wind::on_BeginBtn_clicked()
{
    this->close();
    emit changeTotalWindow();
}


void setup4wind::on_pushButton_10_clicked()
{
    if(doorStatus.get()==0)
    {
        doorStatus.set(1);
        ui->pushButton_10->setText("        关闭仓门");
    }
    else
    {
        doorStatus.set(0);
        ui->pushButton_10->setText("        打开仓门");
    }
}

